<ol class="breadcrumb">
    <li><a href="#">奇妙云箱</a></li>
    <li><a href="/box/list">箱子管理</a></li>
    <li>活动管理</li>
</ol>
<div class="panel panel-default">
    <div class="panel-heading">
        <span class="glyphicon glyphicon-list"></span>
        <span class="panel-title">活动列表</span>
        <a href="/box/active/create?boxid=<%= boxid %>" class="pull-right btn btn-success btn-sm"
           style="margin-top: -3px;">
            <span class="glyphicon glyphicon-plus"></span>
            <span>新增</span>
        </a>
    </div>
    <div class="table-responsive">
        <table class="table table-hover table-striped">
            <thead>
            <tr>
                <th>箱子ID</th>
                <th>活动名称</th>
                <th>活动图片</th>
                <th>创建时间</th>
                <th>操作</th>
            </tr>
            </thead>
            <tfoot>
            <tr>
                <td colspan="7">
                    <nav class="twbsPagination"></nav>
                </td>
            </tr>
            </tfoot>
            <tbody>
            <% for(var i = 0;i < datas.length;i++){ %>
            <tr>
                <td><%= datas[i].box_id %></td>
                <td><%= datas[i].activename %></td>
                <td><img src="<%= datas[i].imgurl %>" style="height: 50px;"></td>
                <td><%= datas[i].date %></td>
                <td>
                    <a href="/box/active/remove?id=<%= datas[i]._id %>" onclick="return confirm('确定删除该箱子?')" class="btn btn-danger btn-sm">删除</a>
                </td>
            </tr>
            <% } %>
            </tbody>
        </table>
    </div>
</div>
<script type="text/javascript">
    $(function () {

        //获得浏览器参数
        $.extend({
            getUrlVars: function () {
                var vars = [], hash;
                var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
                for (var i = 0; i
                < hashes.length; i++) {
                    hash = hashes[i].split('=');
                    vars.push(hash[0]);
                    vars[hash[0]] = hash[1];
                }
                return vars;
            },
            getUrlVar: function (name) {
                return $.getUrlVars()[name];
            }
        });

        //封装浏览器参数
        var composeUrlParams = function () {
            var param = '';
            $.each($.getUrlVars(), function (i, item) {
                if (item != 'p') {
                    var val = $.getUrlVar(item);
                    if (val) param += "&" + item + "=" + val;
                }
            });
            return param;
        }

        //分页功能
        $('.twbsPagination').twbsPagination({
            totalPages: <%= page.pageCount %>,
            visiblePages: 10,
            href: '/box/active/list?num={{number}}'
        });
    })
</script>